home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / compression / xpk / xpkfast.lha / FASTmisc.s < prev    next >
Encoding:
Text File  |  1993-08-21  |  4.7 KB  |  163 lines

  1.  
  2. ; xpk inc
  3.     include "libraries/xpk.i"
  4.     include "libraries/xpksub.i"
  5. ; fast inc
  6.     include    "FAST.i"
  7.  
  8.  
  9.     XDEF    PackChunk
  10.     XDEF    PackReset
  11.     XDEF    PackFree
  12.     XREF    compress_fast
  13.     XREF    _compress_slow
  14.  
  15.     XDEF    UnpackChunk
  16.     XDEF    UnpackFree
  17.     XREF    decompress
  18.  
  19.     XDEF    PackerInfo
  20.  
  21.     XLIB    AllocMem
  22.     XLIB    FreeMem
  23.  
  24.     CODE
  25.  
  26. PACKCHUNKREGS    reg    a0-a6/d1
  27. PackChunk:
  28.     movem.l    PACKCHUNKREGS,-(a7)
  29.     move.l    a6,a5    ;lib base
  30.     move.l    a0,a4    ;xparams
  31.     move.l    xid_SysLib(a5),a6
  32.     tst.l    xsp_Sub(a4)        ;Is there some memory allocated?
  33.     bne.s    packMemOK
  34.     move.l    #PACKMEM,d0
  35.     move.l    #$10001,d1
  36.     CALLSYS    AllocMem
  37.     move.l    d0,xsp_Sub(a4)
  38.     bne.s    packMemOK
  39.     move.l    #XPKERR_NOMEM,d0
  40.     bra.s    endPackChunk
  41.  
  42. packMemOK:
  43.     move.l    xsp_InBuf(a4),a0    ;a0:=InBuf
  44.     move.l    xsp_OutBuf(a4),a1    ;a1:=OutBuf
  45.     move.l    xsp_Sub(a4),a2        ;a2:=Hash
  46.     move.l    xsp_InLen(a4),d0    ;d0:=InLen
  47.     moveq.l    #90,d1
  48.     cmp.l    xsp_Mode(a4),d1
  49.     bcc.s    DoFastCompress
  50.     bsr    _compress_slow
  51.     bra.s    finished
  52. DoFastCompress:    
  53.     bsr    compress_fast
  54. finished:    
  55.     tst.l    d0
  56.     bne.s    Nooverrun
  57.     moveq.l    #XPKERR_EXPANSION,d0
  58.     bra.s    endPackChunk
  59. Nooverrun:
  60.     move.l    d0,xsp_OutLen(a4)    ;Fill in Final output length XpkSubParams
  61.     moveq    #XPKERR_OK,d0
  62. endPackChunk:
  63.     movem.l    (sp)+,PACKCHUNKREGS
  64.     rts
  65.  
  66. PACKFREEREGS    reg    a0-a3/d0-d1
  67. PackFree:    movem.l    PACKFREEREGS,-(a7)
  68.         move.l    xsp_Sub(a0),a1
  69.         beq.s    packFreeEnd
  70.         clr.l    xsp_Sub(a0)
  71.         move.l    #PACKMEM,d0
  72.         move.l    a6,a3
  73.         move.l    xid_SysLib(a3),a6
  74.         CALLSYS    FreeMem
  75.         move.l    a3,a6
  76. packFreeEnd:    movem.l    (a7)+,PACKFREEREGS
  77. UnpackFree:
  78. PackReset:    moveq    #XPKERR_OK,d0
  79.         rts
  80.  
  81. UnpackChunk:    move.l    a1,-(sp)
  82.         move.l    xsp_OutBuf(a0),a1
  83.         move.l    xsp_InLen(a0),d0
  84.         move.l    xsp_InBuf(a0),a0
  85.  
  86.         bsr    decompress
  87.         move.l    (sp)+,a1
  88.         moveq.l    #XPKERR_OK,d0
  89.         rts
  90.  
  91.  
  92. PackerInfo:    move.l    a0,d0
  93.         lea    FastInfo(pc),a0
  94.         exg    a0,d0
  95.         rts
  96.  
  97.     
  98.  
  99. ; --- Static Data --------
  100. FastInfo:
  101.  dc.w    1        ;xi_XpkInfoVersion:Version number of this structure
  102.  dc.w    Version        ;xi_LibVersion   : The version of this sublibrary
  103.  dc.w    2        ;xi_MasterVersion: The required master lib version
  104.  dc.w    0        ;xi_ModesVersion : Longword align
  105.  dc.l    FastName    ;xi_Name         : Brief name of the packer
  106.  dc.l    LongName    ;xi_LongName     : Full name of the packer
  107.  dc.l    Description    ;xi_Description  : One line description of packer
  108.  dc.b   'FAST'        ;xi_ID           : ID the packer goes by (XPK format)
  109.              ;xi_Flags        : Defined below
  110.  dc.l    XPKIF_PK_CHUNK|XPKIF_UP_CHUNK|XPKIF_MODES
  111.  dc.l    $7FFFFFFF    ;xi_MaxPkInChunk : Max input chunk size for packing
  112.  dc.l    0        ;xi_MinPkInChunk : Min input chunk size for packing
  113.  dc.l    $10000        ;xi_DefPkInChunk : Default packing chunk size
  114.  dc.l    PackMsg        ;xi_PackMsg      : Packing message, present tense
  115.  dc.l    UnpackMsg    ;xi_UnpackMsg    : Unpacking message, present tense
  116.  dc.l    PackedMsg    ;xi_PackedMsg    : Packing message, past tense
  117.  dc.l    UnpackedMsg    ;xi_UnpackedMsg  : Unpacking message, past tense
  118.  dc.w    50        ;xi_DefMode      : Default mode number
  119.  dc.w    0        ;xi_Pad          : for future use
  120.  dc.l    Modes        ;xi_Modes        : Array of compression modes
  121.  dc.l    0,0,0,0,0,0    ;xi_Reserved,6*4 : Future expansion - set to zero
  122.          ;LABEL    ;xi_SIZEOF       : Size of the *first* part only
  123.  
  124. FastName:    dc.b    'fasTcinator',0
  125. LongName:    dc.b    'FAST V'
  126.         VERSIONSTR
  127.         dc.b    ' alias WOOP or LZRW++',0
  128. Description:    dc.b    'LZ77-family, windowsize: 4095, no quotecount, 2 streams',0
  129. PackMsg:    dc.b    'tieing',0
  130. PackedMsg:    dc.b    'compressed',0
  131. UnpackMsg:    dc.b    'untieing',0
  132. UnpackedMsg:    dc.b    'decompressed',0
  133.  
  134.     EVEN
  135.  
  136. Modes:
  137.  dc.l    Crawling    ;xm_Next          : Chain to next descriptor for ModeDesc list
  138.  dc.l    89        ;xm_Upto          : Maximum efficiency handled by this mode.
  139.              ;xm_Flags         : Defined below
  140.  dc.l    XPKMF_A3000SPEED
  141.  dc.l    PACKMEM        ;xm_PackMemory    : Extra memory required during packing
  142.  dc.l    UNPACKMEM    ;xm_UnpackMemory  : Extra memory during unpacking
  143.  dc.l    426        ;xm_PackSpeed     : Approx packing speed in K per second
  144.  dc.l    1048        ;xm_UnpackSpeed   : Approx unpacking speed in K per second
  145.  dc.w    327        ;xm_Ratio         : CF in 0.1% for AmigaVision executable
  146.  dc.w    0        ;xm_ChunkSize     : Desired chunk size in K (!!) for this mode
  147.  dc.b    'speedy',0,0,0,0 ;xm_Description,10:8 character mode description
  148.  
  149. Crawling:
  150.  dc.l    0        ;xm_Next          : Chain to next descriptor for ModeDesc list
  151.  dc.l    100        ;xm_Upto          : Maximum efficiency handled by this mode.
  152.              ;xm_Flags         : Defined below
  153.  dc.l    XPKMF_A3000SPEED
  154.  dc.l    PACKMEM        ;xm_PackMemory    : Extra memory required during packing
  155.  dc.l    UNPACKMEM    ;xm_UnpackMemory  : Extra memory during unpacking
  156.  dc.l    52        ;xm_PackSpeed     : Approx packing speed in K per second
  157.  dc.l    1082        ;xm_UnpackSpeed   : Approx unpacking speed in K per second
  158.  dc.w    393        ;xm_Ratio         : CF in 0.1% for AmigaVision executable
  159.  dc.w    0        ;xm_ChunkSize     : Desired chunk size in K (!!) for this mode
  160.  dc.b    'crawling',0,0    ;xm_Description,10:8 character mode description
  161.         ;LABEL    ;xm_SIZEOF
  162.     END
  163.